cmake_minimum_required(VERSION 3.22.1)

project(chat-app VERSION 1.0 LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# 设置默认构建类型为Debug，如果未指定
if(NOT CMAKE_BUILD_TYPE)
  set(CMAKE_BUILD_TYPE Debug)
endif()

# 查找Qt6库
find_package(Qt6 COMPONENTS Widgets Network Multimedia REQUIRED)

set(CMAKE_AUTOMOC ON) # 启用自动 MOC 处理
set(CMAKE_AUTORCC ON)  # 启用自动 RCC 处理

set(PROJECT_SOURCES
    main.cpp
    chatwindow.cpp
    chatwindow.h
)

# 添加资源文件
set(PROJECT_RESOURCES resources.qrc)

Qt6_add_resources(PROJECT_RESOURCES_RCC ${PROJECT_RESOURCES})

add_executable(chatApp ${PROJECT_SOURCES} ${PROJECT_RESOURCES_RCC})

# 链接Qt6库
target_link_libraries(chatApp Qt6::Widgets Qt6::Network Qt6::Multimedia)

# 添加编译选项
target_compile_options(chatApp PRIVATE -Wall)

# 生成GDB配置文件
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
